package com.example.day1402;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author Lenovo
 */
public class ListDemo {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        Student s1 = new Student("林青霞", 30);
        Student s2 = new Student("风清扬", 33);
        Student s3 = new Student("张曼玉", 18);
        list.add(String.valueOf(s1));
        list.add(String.valueOf(s2));
        list.add(String.valueOf(s3));
        Iterator<String> it = list.iterator();
        while (it.hasNext()) {
            String s = it.next();
            System.out.println(s.replace() + "," + s.getAge());
        }
        System.out.println("--------------------------");
        for (int i = 0; i < list.size(); i++) {
            String s = list.get(i);
            System.out.println(s.replace() + "," + s.getAge());
        }
        System.out.println("--------------------------");
        for (String s : list) {
            System.out.println(s.replace() + "," + s.getAge());
        }
    }
}
